#!/bin/bash

ArduinoDev="/dev/ttyACM0"

#Baund Rate (Default: 9600)
ArduinoBaudRate=9600


fail=0

un=$(whoami)
echo "username: "$un


gr=$(groups)
echo "groups: "$gr

info=$(ls -l $ArduinoDev)
echo "device: $ArduinoDev "$info

echo "selected Baund Rare: "$ArduinoBaudRate

echo -n "file type: "
if [ -c $ArduinoDev ]
then
	echo "OK"
else
	echo "fail"
fi

echo -n "read permsision: "
if [ -r $ArduinoDev ]
then
	echo "OK";
else
	echo "missing";
	fail=1
fi

echo -n "write permsision: "
if [ -w $ArduinoDev ]
then
        echo "OK";
else
        echo "missing";
	fail=1
fi


echo -n "screen program: "
pr=$(whereis screen)
if [ ${#pr} -gt 10 ]
then
	echo "OK"
else
	echo "no screen progam (sudo apt-get install screen)"
	fail=1
fi


if [ $fail -eq 1 ]
then
        echo "fail"
        exit
fi


sleep 3

sudo stty -F $ArduinoDev cs8 $ArduinoBaudRate ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
screen $ArduinoDev $ArduinoBaudRate
